<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" href="../../css/reset.css" />
		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />

		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body class="ly-bgcolor">
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<a id="headRightImage" style="color: #e83023;" href="person_withdrawApplication.html">提现记录</a>
					<p id="headTitle">提现</p>
				</div>
				<div id="content" style="padding-bottom: 1.319444rem;">
					<!--基本信息-->
					<div class="ly-info">
						<div>
							<span class="ly-info-title">基本信息</span>
						</div>
						<ul class="ly-info-ul">
							<li class="ly-info-li" style="border-bottom-width: 0px;">
								<a>
									<span style="overflow: hidden;text-overflow:ellipsis;white-space: nowrap;" class="ly-info-span">用户名 ：<span id="userId"></span></p>
									<!--<img class="headRightImg" src="../../images/personage/more.png"/>-->
								</a>
							</li>
							<li class="ly-info-li" style="border-bottom-width: 0px;">
								<a>
									<span class="ly-info-span">仁和币余额 ：<span id="rhGold"></span></span>
								</a>
							</li>
							<li class="ly-info-li" style="border-bottom-width: 0px;">
								<a>
									<span class="ly-info-span">注明：人民币：仁和币 =1：1</span>
								</a>
							</li>

						</ul>
					</div>
					<!--添加信息-->
					<div class="ly-info" style="margin-top: 0.3rem;padding-bottom: 0.5rem;">
						<div>
							<span class="ly-info-title">添加信息</span>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">提现金额:</label>
							<div class="col-xs-8"><input id="money" type="number" class="form-control" /></div>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">联系方式:</label>
							<div class="col-xs-8"><input id="phone" class="form-control" /></div>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">银行卡号:</label>
							<div class="col-xs-8"><input id="card" type="number" class="form-control" /></div>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">持卡人姓名</label>
							<div class="col-xs-8"><input id="userNameCkr" type="text" class="form-control" /></div>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">开户行</label>
							<div class="col-xs-8"><input id="buapSpare2" type="text" class="form-control" /></div>
						</div>
						<a style="display: block;" class="ly-borderp">提交</a>
					</div>
				</div>
			</div>
		</div>

	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					var check = false;
					for(var i = 0; i < data.roleList.length; i++) {
						var role = data.roleList[i].id;
						var deadline = new Date(data.roleList[i].deadline);
						if(role == "f1" && deadline >= new Date()) {
							check = true;
						}
						if(role == "f2" && deadline >= new Date()) {
							check = true;
						}
					}
					if(!check) {
						window.location.href = "../login/login/login.html";
					}
					user = data.loginName;
					$("#userId").html(user);
					role = data.roleList[0].id; //角色
					goodsId = data.id;

				}
			});
		}
		$(document).ready(function() {
			$.ajax({
				type: "get",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				async: false,
				success: function(data) {
					console.log(data);
					//获取当前登陆会员仁和币
					$.ajax({
						type: "post",
						url: "http://47.104.13.109/coin-service/coin/search2",
						async: true,
						data: {
							rhObject: goodsId
						},
						success: function(data) {
							console.log(data);
							$("#rhGold").html(data);
						}
					});
				}
			});

			$('.ly-borderp').click(function() {
				var pattern1 = /^1\d{10}$/;
				var pattern2 = /^(\d{16}|\d{19})$/;
				var pattern3 = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/; //金额正则
				if($("#money").val() == '' || $("#card").val() == '' || $("#phone").val() == '') {
					return alert("请将信息填写完整");
				}
				if($('#rhGold').html() <= 0) {
					return alert("您的仁和币余额不足");
				}
				if(!pattern3.test($("#money").val())) {
					return alert("请输入正确金额");
				}

				if(parseFloat($('#rhGold').html()) < parseFloat($('#money').val())) {
					return alert("请输入正确金额");
				}
				if(!pattern1.test($("#phone").val())) {
					return alert("请输入正确的手机号码");
				}
				if(!pattern2.test($("#card").val())) {
					return alert("请输入正确的银行卡号");
				}

				var userNameCkr = $("#userNameCkr").val();
				var money = $("#money").val();
				var card = $("#card").val();
				var phone = $("#phone").val();
				var buapSpare2 = $("#buapSpare2").val();

				$.ajax({
					type: "post",
					url: "http://47.104.13.109/applyfor-service/drawmoney/applyfor",
					async: false,
					dataType: "JSON",
					data: {
						"applyforUser": user, //申请人/账号
						"applyforUserId": goodsId, //申请人/账号ID
						"userName": userNameCkr, //持卡人姓名
						"userRole": "f1", //角色
						"money": money, //提现金额
						"cardNo": card, //银行卡号
						"buapSpare1": phone, //联系方式
						"buapSpare2": buapSpare2 //开户行信息
					},
					success: function(data) {
						console.log(data);
						alert(data.message);
						if(data.code == 1){
							history.go(-1);
						}
					}
				});

			});

		});
	</script>

</html>